package icu.sehnen.mail.component;

import icu.sehnen.common.CommonUser;
import icu.sehnen.mail.entity.MailVo;
import icu.sehnen.mail.service.MailService;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Map;
 
/**
 * @Author : JCccc
 * @CreateTime : 2019/9/3
 * @Description :
 **/
@Component
@RabbitListener(queues = "RegisterMsgDirectQueue")
public class DirectReceiver {
    @Autowired
    MailService mailService;
    @RabbitHandler
    public void process(CommonUser commonUser) {
        sendEmail(commonUser);
    }
    public  void sendEmail(CommonUser commonUser){
        MailVo mailVo = MailVo.builder().to(commonUser.getEmail())
                .subject("测试")
                .text("你好，"+ commonUser.getEmail()+"邮箱用户+，你的用户名为"+commonUser.getUsername()+"你的密码为"+commonUser.getPassword()).build();
        mailService.sendMail(mailVo);
    }

}